//
//  RequestManager.h
//  pianke
//
//  Created by lanou3g on 15/6/4.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import <Foundation/Foundation.h>




//定义枚举，枚举类型请求的类型
typedef NS_ENUM(NSInteger, RequestModel){
    
    POST,
    GET
    
};

@protocol RequestDelegate <NSObject>

//请求完毕之后让代理对象执行的方法，同时把请求完整的data传给代理对象
- (void)requestDidFinishWithData:(NSData *)data;
//请求失败后把错误原因传值给代理对象
- (void)requestError:(NSError *)error;

@end


@interface RequestManager : NSObject<NSURLConnectionDataDelegate>

@property (nonatomic ,retain)NSString *requestURL;//请求网址

@property (nonatomic ,retain)NSString *requestParameter;//请求参数

@property (nonatomic ,retain)NSMutableDictionary *parameterDic;//参数字典

@property (nonatomic ,assign)RequestModel requestModel;//请求类型

@property (nonatomic ,retain)NSMutableData *data;//接受返回的数据

@property (nonatomic ,assign)id<RequestDelegate> delegate;//保存代理对象

//初始化方法
- (instancetype)initWithRequestURL:(NSString *)urlString requestModel:(RequestModel)requestModel parameter:(NSString *)parameter;

//手动开始请求的方法
- (void)startRequest;



@end
